{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {
    "slideshow": {
     "slide_type": "-"
    }
   },
   "source": [
    "# 列表的定义"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "定义一个一维列表 `1,2,3,4`"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "定义一个一维列表 `a, bcd, e, fg, h`"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "定义一个一维列表 `1, 1.2, 3ab, efg`"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "定义一个二维列表:\n",
    "```\n",
    "1 2 3\n",
    "4 5 6\n",
    "7 8 9\n",
    "```"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "scrolled": false
   },
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "定义一个二维列表:\n",
    "```\n",
    "1   ab   [1,2]  2\n",
    "c   [1,4,5,6]\n",
    "48  9    \n",
    "```"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "scrolled": true
   },
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### 以下`md`是一个二维列表，格式如下:\n",
    "```\n",
    "[ ['201652270102', '曹青森'], ['201752180127', '姚博瀚'] ]\n",
    "```\n",
    "可见该列表中的每一个元素也是一个列表，小列表包括两个元素:\n",
    "1. 学号\n",
    "2. 姓名\n",
    "请打印出来整个列表有多少个同学?"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "md=[x.strip().split(\"\\t\") for x in open('学生名单.txt')]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 列表的访问"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "获得二维列表:\n",
    "```\n",
    "1   ab   [1,222]  2\n",
    "c   [0,0,0]\n",
    "48  9    \n",
    "```\n",
    "中的`222`"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "请获得以下列表`md`前10位同学的信息"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "md=[x.strip().split(\"\\t\") for x in open('学生名单.txt')]\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### 请随便选一个数字, 假设你选择的数字是23，请写一段程序产生如下结果:\n",
    "```\n",
    "第 23 位同学的姓名是: XXX 学号是: XXXXXXXX\n",
    "```"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "scrolled": false
   },
   "source": [
    "# 列表的遍历"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "写程序遍历列表:\n",
    "```\n",
    "1 2 3\n",
    "4 5 6\n",
    "7 8 9\n",
    "```\n",
    "打印出来如下结果:\n",
    "```\n",
    "2 3 4\n",
    "5 6 7\n",
    "8 9 10\n",
    "```"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "scrolled": false
   },
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "scrolled": false
   },
   "source": [
    "#### 请遍历以下列表`md`，并把第30到第80名同学的姓名和学号按照如下格式打印出来\n",
    "```\n",
    "姓名:XXX 学号:XXXX\n",
    "```"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "scrolled": false
   },
   "outputs": [],
   "source": [
    "md=[x.strip().split(\"\\t\") for x in open('学生名单.txt')]"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.7"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
